package acm.蓝桥16;

import java.io.*;
import java.util.*;

public class F网线链接 {
    /**
     * 一个无向单连通图，每个点的权值为与之链接的点的数量
     * m次询问，弗洛伊德？
     */

    static int maxN=100000,maxM=100000;
    static int w[];
    static List<Integer>[] nodes;
    static Map<Integer,int[]> disMap=new HashMap<>();   //存储结果
    static int n,m;

    public static void main(String[] args) {
        Reader sc=new Reader();
        n = sc.nextInt();
        m = sc.nextInt();
        nodes = new List[n + 1];
        w = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            nodes[i] = new ArrayList<>();
        }
        for (int i = 1; i < n; i++) {
            int u = sc.nextInt();
            int v = sc.nextInt();
            nodes[u].add(v);
            nodes[v].add(u);
            w[v]++;
            w[u]++;
        }
        for (int i = 0; i < m; i++) {
            int u = sc.nextInt();
            int v = sc.nextInt();
            int[] dis = disMap.get(u);
            if (dis==null){
                dis = djs(u);
                disMap.put(u,dis);
            }
            System.out.println(dis[v]);
        }

    }
    public static int[] djs(int s){
        int[] dis=new int[n+1];
        Arrays.fill(dis,Integer.MAX_VALUE);
        boolean[] vis = new boolean[n + 1];
        int cnt = 0;
        PriorityQueue<int[]> queue = new PriorityQueue<>((a, b) ->a[1]-b[1]);    //0位置id，1位置距离
        queue.add(new int[]{s, w[s]});
        dis[s]=w[s];
        while (!queue.isEmpty() && cnt < n) {
            int[] poll = queue.poll();
            int id = poll[0];
            if (vis[id]) continue;
            int v = poll[1];
            cnt++;
            vis[id]=true;
            for (Integer to : nodes[id]) {
                int d=v+w[to];
                if (d<dis[to]){
                    dis[to]=d;
                    queue.add(new int[]{to,d});
                }
            }
        }
        return dis;
    }
    static class Reader {
        private StreamTokenizer tokenizer=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        private PrintWriter pr=new PrintWriter(new BufferedOutputStream(System.out));
        public int nextInt(){
            try {
                tokenizer.nextToken();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (int) tokenizer.nval;
        }
    }

}
